// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Tube Cover Object
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 78 : TYPE_TUBECOVER


// Static Values

// Tables

event ObjectMain
	switch object.state
	case 0
		break
	case 2
		temp1 = object.ypos
		temp1 -= 0x200000
		CreateTempObject(TypeName[Smoke Puff], 0, object.xpos, temp1)
		object[tempObjectPos].drawOrder = 5
		object.state++
		break
	case 1
	case 3
	case 5
	case 7
		object.value0++
		if object.value0 == 16
			object.value0 = 0
			object.state++
		end if
		break
	case 4
		temp0 = object.xpos
		temp0 -= 0x100000
		temp1 = object.ypos
		temp1 -= 0x200000
		CreateTempObject(TypeName[Smoke Puff], 0, temp0, temp1)
		object[tempObjectPos].drawOrder = 5
		temp0 += 0x200000
		CreateTempObject(TypeName[Smoke Puff], 0, temp0, temp1)
		object[tempObjectPos].drawOrder = 5
		object.state++
		break
	case 6
		temp0 = object.xpos
		temp0 -= 0x200000
		temp1 = object.ypos
		temp1 -= 0x200000
		CreateTempObject(TypeName[Smoke Puff], 0, temp0, temp1)
		object[tempObjectPos].drawOrder = 5
		temp0 += 0x400000
		CreateTempObject(TypeName[Smoke Puff], 0, temp0, temp1)
		object[tempObjectPos].drawOrder = 5
		object.state++
		break
	case 8
		object.ypos += object.yvel
		object.value1 += object.yvel
		object.yvel += 0x2800
		object.value0++
		if object.value0 == 60
			object.state++
		end if
		break
	end switch
	if object.state == 1
	end if
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		BoxCollisionTest(C_BOX, object.entityPos, -32, -32, 32, 32, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
	next
end event


event ObjectDraw
	temp0 = object.ypos
	temp0 -= object.value1
	DrawSpriteXY(1, object.xpos, temp0)
	DrawSprite(0)
end event


event ObjectStartup
	LoadSpriteSheet("SBZ/Objects.gif")
	SpriteFrame(-32, -32, 64, 64, 317, 339)
	SpriteFrame(-32, -8, 32, 40, 2, 472)
	foreach (TypeName[Tube Cover], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].drawOrder = 4
	next
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
